﻿using Kingdee.BOS;
using Kingdee.BOS.App.Data;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.Util;
using Kingdee.BOS.WebApi.Client;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WSDZ.KM.ZH.XiaoManIntegrating40
{
    /// <summary>
    /// 小满
    /// </summary>
    [Description("客户|联系人数据字典【本地测试用】"), HotUpdate]
    public class CompanyfieldsJob : AbstractOperationServicePlugIn
    {
        public string btype = "客户|联系人数据字典";
        /// <summary>
        /// 日志文件路径
        /// </summary>
        public string logType = "客户|联系人数据字典";
        public TokenData TokenObj = null;
        public string client_url { get; set; } = "https://api-sandbox.xiaoman.cn/v1/company/fields";
        Dictionary<string, string> headers = new Dictionary<string, string>() {
            //{"AccessKeyId",CommonData.AccessKeyId },
            //{"AccessKeySecret",CommonData.AccessKeySecret }
        };

        public void Main()
        {
            try
            {
                var tokens = PostHelper.GetToken(logType);
                if (!tokens.Item1)
                {
                    LogHelper.XiaoManLog($"【获取token错误】【msg:{tokens.Item2.msg}】");
                    return;
                }
                TokenObj = tokens.Item2;
                Dictionary<string, string> headers = new Dictionary<string, string>();
                headers.Add("Authorization", $@"Bearer {TokenObj.token}");
                string resultStr = PostHelper.Get(client_url, "", headers);
                LogHelper.XiaoManLog($"【客户|联系人数据字典】\nheaders:{JsonConvert.SerializeObject(headers)}\n返回:{resultStr}");
            }
            catch (Exception ex)
            {
                LogHelper.XiaoManLog($"【异常A1001】【msg:{ex.Message}】");
            }

        }




    }
}
